#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // 将输入的格式设置为密码
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
}

Widget::~Widget()
{
    delete ui;
}



void Widget::on_lineEdit_textEdited(const QString &text)
{
    compare();
}

void Widget::on_lineEdit_2_textEdited(const QString &arg1)
{
    compare();
}

void Widget::compare()
{
    QString password1 = ui->lineEdit->text();
    QString password2 = ui->lineEdit_2->text();

    if (password1 == password2)
        ui->label->setText("两次密码一样");
    else
        ui->label->setText("两次密码不一致");
}



